Skip to content

Conversation

@noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Dec 8, 2025

This PR refines the TypeVar instantiation logic introduced by #24231.

We only check the calleeType when there is actually a TypeVar in pt to instantiate now, prioritizing inference from the callee.

Close #24686 #24689 #24694 #24696

Maybe #24695, since the behaviour is the same as 3.3 and 3.7 now.

calleeType itself still has some issues, will fix in a separate PR: #24732

This comment was marked as resolved.

@noti0na1 noti0na1 force-pushed the fix-function-param-placeholder-symbols branch from 36dc33a to dc3281e Compare December 11, 2025 15:08
@noti0na1 noti0na1 changed the title Create placeholder symbols for checking callee and improve TypeVar instantiation logic Improve TypeVar instantiation logic Dec 12, 2025
@noti0na1 noti0na1 merged commit 2209ad5 into scala:main Dec 12, 2025
46 checks passed
@noti0na1 noti0na1 deleted the fix-function-param-placeholder-symbols branch December 12, 2025 13:45
noti0na1 added a commit that referenced this pull request Dec 12, 2025
The callee part is separated from #24697 for further investigation 

When typing a function literal's expression to infer the callee type, we
now create placeholder tree for each argument, and make sure the
function part does not refer to any parameter. This ensures that
references in the expression won't incorrectly resolve to outer scope
variables with the same names as the parameters.

Fix the following test:

```scala
def foo[T <: (B => Unit)](f: T) = ???
def transfer(in: A): Unit =
  foo(in => transfer(in)) // error: Found: (in : B) Required: A
def transfer(in: B): Unit = ???
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants